home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Mac Mania 4
/
MacMania 4.toast
/
/
Demo's
/
Igor Demo Pro
/
1 PutContentsIn Igor Pro Folder
/
WaveMetrics Procedures
/
Data Manipulation
/
MatrixToMatrix
< prev
next >
Wrap
Text File
|
1996-01-29
|
1KB
|
41 lines
| MatrixToMatrix
| interpolates or decimates a 2D matrix
#pragma rtGlobals=1 // Use modern global access method.
Macro MatrixToMatrix(inMatrix,outMatrix,factor,mktbl,mkimg)
String inMatrix,outMatrix="matrix"
Variable factor=2 // double each dimension, 4 times as many points
Variable mktbl=2,mkimg=2
Prompt inMatrix,"Input 2D matrix",popup,WaveList("*",";","")
Prompt outMatrix,"Output matrix name"
Prompt factor "Interpolation factor (2 doubles rows and columns, 0.5 halves them)"
Prompt mktbl,"Put output matrix in new table?",popup,"Yes;No"
Prompt mkimg,"Display output matrix as image?",popup,"Yes;No"
Silent 1;PauseUpdate
if( WaveDims($inMatrix) != 2 )
Abort inMatrix+" is not a two-dimensional wave."
endif
Variable rows= DimSize($inMatrix,0)
Variable cols= DimSize($inMatrix,1)
Duplicate/O $inMatrix,$outMatrix
Redimension/N=(rows*factor,cols*factor) $outMatrix
CopyScales/I $inMatrix, $outMatrix
// Make a temporary contour plot
// so we can use ContourZ to interpolate from X,Y,Z into MatrixXY
Display/W=(0,30,200,80) // teeny window
DoWindow/C WM_MatrixtoMatrix
AppendMatrixContour $inMatrix;ModifyContour $inMatrix autoLevels={*,*,0},update=1,labels=0
ModifyGraph axThick=0,nolabel=2;Textbox/A=LC/F=0 "Computing "+outMatrix;DoUpdate
$outMatrix= ContourZ("","",0,x,y)
DoWindow/K WM_MatrixtoMatrix
Preferences 1
if( mktbl == 1)
Edit $outMatrix
endif
if( mkimg == 1)
Display;AppendImage $outMatrix
endif
EndMacro